<template>
  <el-menu
    active-text-color="rgb(64, 158, 255)"
    background-color="rgb(48, 65, 86)"
    class="el-menu-vertical-demo"
    :default-active="route.path"
    text-color="#fff"
    :collapse="menuShow"
    router
    unique-opened
  >
    <el-menu-item index="/index">
      <el-icon><icon-menu /></el-icon>
      <span>首页</span>
    </el-menu-item>
    <el-sub-menu :index="'/' + item.name" v-for="item in menus" :key="item.id">
      <template #title>
        <i class="iconfont" :class="item.icon"></i>
        <span>{{ item.title }}</span>
      </template>
      <template v-for="cItem in item.children" :key="cItem.id">
        <el-menu-item
          :index="'/' + item.name + '/' + cItem.name"
          v-if="cItem.hidden === 0"
        >
          <i class="iconfont" :class="cItem.icon"></i>
          {{ cItem.title }}
        </el-menu-item>
      </template>
    </el-sub-menu>
  </el-menu>
</template>

<script lang="ts" setup>
import { inject, ref } from "vue";
import {
  Document,
  Menu as IconMenu,
  Location,
  Setting,
} from "@element-plus/icons-vue";
import { useUserStore } from "@/store/user";
import { useRoute } from "vue-router";
import { watch } from "vue";
const userStore = useUserStore();
const menuShow = inject("menuShow");
const menus = userStore.routes;
const route = useRoute();
// const defUrl = ref("/index")
// watch(()=>route.path,()=>{
//   defUrl.value = route.path
// },{immediate:true})
</script>

<style lang="scss" scoped>
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 200px;
  min-height: 400px;
}
// :deep(.el-menu) {
//   border-right: solid 5px !important;
// }
</style>
